/**
 * 
 */
package org.dragonfire.util;

import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.Window;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 * @author Darth Android
 * @date Nov 13, 2007
 */
public class DSwing {

	public static void centerOnScreen(Window frame) {
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2);
	}

	public static void useSystemLookAndFeel() {
		try {
			// Set System L&F
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (UnsupportedLookAndFeelException e) {
			// ignore & use metal
		} catch (ClassNotFoundException e) {
			// ignore & use metal
		} catch (InstantiationException e) {
			// ignore & use metal
		} catch (IllegalAccessException e) {
			// ignore & use metal
		}
	}

	public static class GridBagConstraints extends java.awt.GridBagConstraints {

		/**
		 * 
		 */
		public GridBagConstraints() {
			super();
			this.weightx = 1.0;
			this.anchor = GridBagConstraints.WEST;
		}

		public GridBagConstraints(int gridx, int gridy) {
			this();
			this.gridx = gridx;
			this.gridy = gridy;
		}

		public GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight) {
			this(gridx, gridy);
			this.gridheight = gridheight;
			this.gridwidth = gridwidth;
		}

		/**
		 * {@inheritDoc}
		 */
		public GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty,
				int anchor, int fill, Insets insets, int ipadx, int ipady) {
			super(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, insets, ipadx, ipady);
		}

	}
}
